//
//  SWOrderPagesUpdateReq.swift
//  ChildStory
//
//  Created by linhan on 2017/2/5.
//  Copyright © 2017年 Aiya. All rights reserved.
//

import Foundation
class SWOrderPagesUpdateReq: SWBaseRequest
{
    var pages:[SWPage] = []
    var orderID:String = ""
    
    override init()
    {
        super.init()
        api = SWRequestAPI.AddressCreate
    }
    
    override var url:String
    {
        return "http://mpic.bbyiya.com/order/saveProductOrderDetail"
    }
    
    override var params:Any?
    {
        var list:[[String:Any]] = []
        var data:[String:Any] = [:]
        for page in pages
        {
            if let url = page.largeResultURL
            {
                list.append(["imageUrl":url, "printNo":"123"])
            }
        }
        data["imageList"] = list
        data["orderId"] = orderID
        
        let jsonString:String = JSONHelper.JSONEncode(data)
        //trace("SWOrderPagesUpdateReq", jsonString)
        
        return ["orderImagesJson":jsonString]
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        //trace(json)
        return Mapper<SWOrderPagesUpdateRsp>().map(JSONString: JSONString)
    }
}

class SWOrderPagesUpdateRsp: NSObject,Mappable
{
    var statu:String?
    
    
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        statu             <- map["Statu"]
    }
}
